/*
 * Package il.ac.biu.cs.grossmm.api.data
 * File NodeEventInspector.java
 * 
 * This is a part of presence service framework API. 
 * See javadoc for more information.
 *  
 * Copyright (C) 2006 Grossmann Mark
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.

 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
 * MA  02110-1301, USA.
 */

package il.ac.biu.cs.grossmm.api.flow;

import il.ac.biu.cs.grossmm.api.OperationFailedException;
import il.ac.biu.cs.grossmm.api.data.Node;
import il.ac.biu.cs.grossmm.api.data.Nodeset;
import il.ac.biu.cs.grossmm.api.data.Property;
import il.ac.biu.cs.grossmm.api.data.UpdateType;

import java.util.Set;

/**
 * Contains methods to inspect changes applied to data node. Instances of this
 * class are provided as arguments in <tt>Subscriber.notify</tt> method, which
 * is invoked on node modification events.
 */
public interface NodeEventInspector extends NodeInspector {
	/**
	 * Gets update type of the node. There are four update types (as represented
	 * by <tt>UpdateType</tt> enum):
	 * <ul>
	 * <li> UNCHANGED
	 * <li> CHANGED
	 * <li> ADDED
	 * <li> REMOVED
	 * </ul>
	 * 
	 * @param <N>
	 *            Node type interface
	 * @param node
	 *            the node to inspect
	 * @return update type of this node
	 */
	<N> UpdateType getUpdateType(Node<N> node);

	/**
	 * Gets a old (before update) value of a property of a data node
	 * 
	 * @param <N>
	 *            Node type interface
	 * @param <V>
	 *            Property type
	 * @param node
	 *            node to inspect
	 * @param property
	 *            propery in this node to inspect
	 * @return old value of this property
	 * @throws OperationFailedException
	 */
	<N, V> V getOldValue(Node<N> node, Property<N, V> property)
		throws OperationFailedException;

	/**
	 * Queries for subnodes with a given update type, where type is one of the
	 * followring:
	 * <ul>
	 * <li> UNCHANGED
	 * <li> CHANGED
	 * <li> ADDED
	 * <li> REMOVED
	 * </ul>
	 * 
	 * @param <N>
	 *            Node type interface of the node being queried
	 * @param <S>
	 *            Node type interface of subnodes
	 * @param node
	 *            the node of interest
	 * @param nodeSet
	 *            node-set of interest
	 * @param u
	 *            update type
	 * @return set of subnodes with a given update type
	 * @throws OperationFailedException
	 */
	<N, S> Set<Node<S>> getSubnodes(Node<N> node, Nodeset<N, S> nodeSet,
		UpdateType u) throws OperationFailedException;
}
